home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / stl / stl_hash_map.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-08  |  20.0 KB  |  533 lines

  1. /*
  2.  * Copyright (c) 1996
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Permission to use, copy, modify, distribute and sell this software
  6.  * and its documentation for any purpose is hereby granted without fee,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.  Silicon Graphics makes no
  10.  * representations about the suitability of this software for any
  11.  * purpose.  It is provided "as is" without express or implied warranty.
  12.  *
  13.  *
  14.  * Copyright (c) 1994
  15.  * Hewlett-Packard Company
  16.  *
  17.  * Permission to use, copy, modify, distribute and sell this software
  18.  * and its documentation for any purpose is hereby granted without fee,
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both that copyright notice and this permission notice appear
  21.  * in supporting documentation.  Hewlett-Packard Company makes no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied warranty.
  24.  *
  25.  */
  26.  
  27. /* NOTE: This is an internal header file, included by other STL headers.
  28.  *   You should not attempt to use it directly.
  29.  */
  30.  
  31. #ifndef __SGI_STL_INTERNAL_HASH_MAP_H
  32. #define __SGI_STL_INTERNAL_HASH_MAP_H
  33.  
  34. #include <concept_checks.h>
  35.  
  36. __STL_BEGIN_NAMESPACE
  37.  
  38. #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
  39. #pragma set woff 1174
  40. #pragma set woff 1375
  41. #endif
  42.  
  43. // Forward declaration of equality operator; needed for friend declaration.
  44.  
  45. template <class _Key, class _Tp,
  46.           class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),
  47.           class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),
  48.           class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Tp) >
  49. class hash_map;
  50.  
  51. template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
  52. inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
  53.                        const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
  54.  
  55. template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
  56.           class _Alloc>
  57. class hash_map
  58. {
  59.   // requirements:
  60.  
  61.   __STL_CLASS_REQUIRES(_Key, _Assignable);
  62.   __STL_CLASS_REQUIRES(_Tp, _Assignable);
  63.   __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
  64.   __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);
  65.  
  66. private:
  67.   typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
  68.                     _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
  69.   _Ht _M_ht;
  70.  
  71. public:
  72.   typedef typename _Ht::key_type key_type;
  73.   typedef _Tp data_type;
  74.   typedef _Tp mapped_type;
  75.   typedef typename _Ht::value_type value_type;
  76.   typedef typename _Ht::hasher hasher;
  77.   typedef typename _Ht::key_equal key_equal;
  78.   
  79.   typedef typename _Ht::size_type size_type;
  80.   typedef typename _Ht::difference_type difference_type;
  81.   typedef typename _Ht::pointer pointer;
  82.   typedef typename _Ht::const_pointer const_pointer;
  83.   typedef typename _Ht::reference reference;
  84.   typedef typename _Ht::const_reference const_reference;
  85.  
  86.   typedef typename _Ht::iterator iterator;
  87.   typedef typename _Ht::const_iterator const_iterator;
  88.  
  89.   typedef typename _Ht::allocator_type allocator_type;
  90.  
  91.   hasher hash_funct() const { return _M_ht.hash_funct(); }
  92.   key_equal key_eq() const { return _M_ht.key_eq(); }
  93.   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  94.  
  95. public:
  96.   hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
  97.   explicit hash_map(size_type __n)
  98.     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  99.   hash_map(size_type __n, const hasher& __hf)
  100.     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  101.   hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
  102.            const allocator_type& __a = allocator_type())
  103.     : _M_ht(__n, __hf, __eql, __a) {}
  104.  
  105. #ifdef __STL_MEMBER_TEMPLATES
  106.   template <class _InputIterator>
  107.   hash_map(_InputIterator __f, _InputIterator __l)
  108.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  109.     { _M_ht.insert_unique(__f, __l); }
  110.   template <class _InputIterator>
  111.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
  112.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  113.     { _M_ht.insert_unique(__f, __l); }
  114.   template <class _InputIterator>
  115.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  116.            const hasher& __hf)
  117.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  118.     { _M_ht.insert_unique(__f, __l); }
  119.   template <class _InputIterator>
  120.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  121.            const hasher& __hf, const key_equal& __eql,
  122.            const allocator_type& __a = allocator_type())
  123.     : _M_ht(__n, __hf, __eql, __a)
  124.     { _M_ht.insert_unique(__f, __l); }
  125.  
  126. #else
  127.   hash_map(const value_type* __f, const value_type* __l)
  128.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  129.     { _M_ht.insert_unique(__f, __l); }
  130.   hash_map(const value_type* __f, const value_type* __l, size_type __n)
  131.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  132.     { _M_ht.insert_unique(__f, __l); }
  133.   hash_map(const value_type* __f, const value_type* __l, size_type __n,
  134.            const hasher& __hf)
  135.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  136.     { _M_ht.insert_unique(__f, __l); }
  137.   hash_map(const value_type* __f, const value_type* __l, size_type __n,
  138.            const hasher& __hf, const key_equal& __eql,
  139.            const allocator_type& __a = allocator_type())
  140.     : _M_ht(__n, __hf, __eql, __a)
  141.     { _M_ht.insert_unique(__f, __l); }
  142.  
  143.   hash_map(const_iterator __f, const_iterator __l)
  144.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  145.     { _M_ht.insert_unique(__f, __l); }
  146.   hash_map(const_iterator __f, const_iterator __l, size_type __n)
  147.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  148.     { _M_ht.insert_unique(__f, __l); }
  149.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  150.            const hasher& __hf)
  151.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  152.     { _M_ht.insert_unique(__f, __l); }
  153.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  154.            const hasher& __hf, const key_equal& __eql,
  155.            const allocator_type& __a = allocator_type())
  156.     : _M_ht(__n, __hf, __eql, __a)
  157.     { _M_ht.insert_unique(__f, __l); }
  158. #endif /*__STL_MEMBER_TEMPLATES */
  159.  
  160. public:
  161.   size_type size() const { return _M_ht.size(); }
  162.   size_type max_size() const { return _M_ht.max_size(); }
  163.   bool empty() const { return _M_ht.empty(); }
  164.   void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
  165.  
  166. #ifdef __STL_MEMBER_TEMPLATES
  167.   template <class _K1, class _T1, class _HF, class _EqK, class _Al>
  168.   friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
  169.                           const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
  170. #else /* __STL_MEMBER_TEMPLATES */
  171.   friend bool __STD_QUALIFIER
  172.   operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);
  173. #endif /* __STL_MEMBER_TEMPLATES */
  174.  
  175.  
  176.   iterator begin() { return _M_ht.begin(); }
  177.   iterator end() { return _M_ht.end(); }
  178.   const_iterator begin() const { return _M_ht.begin(); }
  179.   const_iterator end() const { return _M_ht.end(); }
  180.  
  181. public:
  182.   pair<iterator,bool> insert(const value_type& __obj)
  183.     { return _M_ht.insert_unique(__obj); }
  184. #ifdef __STL_MEMBER_TEMPLATES
  185.   template <class _InputIterator>
  186.   void insert(_InputIterator __f, _InputIterator __l)
  187.     { _M_ht.insert_unique(__f,__l); }
  188. #else
  189.   void insert(const value_type* __f, const value_type* __l) {
  190.     _M_ht.insert_unique(__f,__l);
  191.   }
  192.   void insert(const_iterator __f, const_iterator __l)
  193.     { _M_ht.insert_unique(__f, __l); }
  194. #endif /*__STL_MEMBER_TEMPLATES */
  195.   pair<iterator,bool> insert_noresize(const value_type& __obj)
  196.     { return _M_ht.insert_unique_noresize(__obj); }    
  197.  
  198.   iterator find(const key_type& __key) { return _M_ht.find(__key); }
  199.   const_iterator find(const key_type& __key) const 
  200.     { return _M_ht.find(__key); }
  201.  
  202.   _Tp& operator[](const key_type& __key) {
  203.     return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
  204.   }
  205.  
  206.   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
  207.   
  208.   pair<iterator, iterator> equal_range(const key_type& __key)
  209.     { return _M_ht.equal_range(__key); }
  210.   pair<const_iterator, const_iterator>
  211.   equal_range(const key_type& __key) const
  212.     { return _M_ht.equal_range(__key); }
  213.  
  214.   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
  215.   void erase(iterator __it) { _M_ht.erase(__it); }
  216.   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  217.   void clear() { _M_ht.clear(); }
  218.  
  219.   void resize(size_type __hint) { _M_ht.resize(__hint); }
  220.   size_type bucket_count() const { return _M_ht.bucket_count(); }
  221.   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  222.   size_type elems_in_bucket(size_type __n) const
  223.     { return _M_ht.elems_in_bucket(__n); }
  224. };
  225.  
  226. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  227. inline bool 
  228. operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  229.            const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  230. {
  231.   return __hm1._M_ht == __hm2._M_ht;
  232. }
  233.  
  234. #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
  235.  
  236. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  237. inline bool 
  238. operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  239.            const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
  240.   return !(__hm1 == __hm2);
  241. }
  242.  
  243. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  244. inline void 
  245. swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  246.      hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  247. {
  248.   __hm1.swap(__hm2);
  249. }
  250.  
  251. #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
  252.  
  253. // Forward declaration of equality operator; needed for friend declaration.
  254.  
  255. template <class _Key, class _Tp,
  256.           class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),
  257.           class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),
  258.           class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Tp) >
  259. class hash_multimap;
  260.  
  261. template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
  262. inline bool 
  263. operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
  264.            const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2);
  265.  
  266. template <class _Key, class _Tp, class _HashFcn, class _EqualKey, 
  267.           class _Alloc>
  268. class hash_multimap
  269. {
  270.   // requirements:
  271.  
  272.   __STL_CLASS_REQUIRES(_Key, _Assignable);
  273.   __STL_CLASS_REQUIRES(_Tp, _Assignable);
  274.   __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
  275.   __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);
  276.  
  277. private:
  278.   typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
  279.                     _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> 
  280.           _Ht;
  281.   _Ht _M_ht;
  282.  
  283. public:
  284.   typedef typename _Ht::key_type key_type;
  285.   typedef _Tp data_type;
  286.   typedef _Tp mapped_type;
  287.   typedef typename _Ht::value_type value_type;
  288.   typedef typename _Ht::hasher hasher;
  289.   typedef typename _Ht::key_equal key_equal;
  290.  
  291.   typedef typename _Ht::size_type size_type;
  292.   typedef typename _Ht::difference_type difference_type;
  293.   typedef typename _Ht::pointer pointer;
  294.   typedef typename _Ht::const_pointer const_pointer;
  295.   typedef typename _Ht::reference reference;
  296.   typedef typename _Ht::const_reference const_reference;
  297.  
  298.   typedef typename _Ht::iterator iterator;
  299.   typedef typename _Ht::const_iterator const_iterator;
  300.  
  301.   typedef typename _Ht::allocator_type allocator_type;
  302.  
  303.   hasher hash_funct() const { return _M_ht.hash_funct(); }
  304.   key_equal key_eq() const { return _M_ht.key_eq(); }
  305.   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  306.  
  307. public:
  308.   hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
  309.   explicit hash_multimap(size_type __n)
  310.     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  311.   hash_multimap(size_type __n, const hasher& __hf)
  312.     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  313.   hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
  314.                 const allocator_type& __a = allocator_type())
  315.     : _M_ht(__n, __hf, __eql, __a) {}
  316.  
  317. #ifdef __STL_MEMBER_TEMPLATES
  318.   template <class _InputIterator>
  319.   hash_multimap(_InputIterator __f, _InputIterator __l)
  320.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  321.     { _M_ht.insert_equal(__f, __l); }
  322.   template <class _InputIterator>
  323.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
  324.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  325.     { _M_ht.insert_equal(__f, __l); }
  326.   template <class _InputIterator>
  327.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  328.                 const hasher& __hf)
  329.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  330.     { _M_ht.insert_equal(__f, __l); }
  331.   template <class _InputIterator>
  332.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  333.                 const hasher& __hf, const key_equal& __eql,
  334.                 const allocator_type& __a = allocator_type())
  335.     : _M_ht(__n, __hf, __eql, __a)
  336.     { _M_ht.insert_equal(__f, __l); }
  337.  
  338. #else
  339.   hash_multimap(const value_type* __f, const value_type* __l)
  340.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  341.     { _M_ht.insert_equal(__f, __l); }
  342.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
  343.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  344.     { _M_ht.insert_equal(__f, __l); }
  345.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  346.                 const hasher& __hf)
  347.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  348.     { _M_ht.insert_equal(__f, __l); }
  349.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  350.                 const hasher& __hf, const key_equal& __eql,
  351.                 const allocator_type& __a = allocator_type())
  352.     : _M_ht(__n, __hf, __eql, __a)
  353.     { _M_ht.insert_equal(__f, __l); }
  354.  
  355.   hash_multimap(const_iterator __f, const_iterator __l)
  356.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  357.     { _M_ht.insert_equal(__f, __l); }
  358.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
  359.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  360.     { _M_ht.insert_equal(__f, __l); }
  361.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  362.                 const hasher& __hf)
  363.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  364.     { _M_ht.insert_equal(__f, __l); }
  365.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  366.                 const hasher& __hf, const key_equal& __eql,
  367.                 const allocator_type& __a = allocator_type())
  368.     : _M_ht(__n, __hf, __eql, __a)
  369.     { _M_ht.insert_equal(__f, __l); }
  370. #endif /*__STL_MEMBER_TEMPLATES */
  371.  
  372. public:
  373.   size_type size() const { return _M_ht.size(); }
  374.   size_type max_size() const { return _M_ht.max_size(); }
  375.   bool empty() const { return _M_ht.empty(); }
  376.   void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
  377.  
  378. #ifdef __STL_MEMBER_TEMPLATES
  379.   template <class _K1, class _T1, class _HF, class _EqK, class _Al>
  380.   friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
  381.                           const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
  382. #else /* __STL_MEMBER_TEMPLATES */
  383.   friend bool __STD_QUALIFIER
  384.   operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,const hash_multimap&);
  385. #endif /* __STL_MEMBER_TEMPLATES */
  386.  
  387.   iterator begin() { return _M_ht.begin(); }
  388.   iterator end() { return _M_ht.end(); }
  389.   const_iterator begin() const { return _M_ht.begin(); }
  390.   const_iterator end() const { return _M_ht.end(); }
  391.  
  392. public:
  393.   iterator insert(const value_type& __obj) 
  394.     { return _M_ht.insert_equal(__obj); }
  395. #ifdef __STL_MEMBER_TEMPLATES
  396.   template <class _InputIterator>
  397.   void insert(_InputIterator __f, _InputIterator __l) 
  398.     { _M_ht.insert_equal(__f,__l); }
  399. #else
  400.   void insert(const value_type* __f, const value_type* __l) {
  401.     _M_ht.insert_equal(__f,__l);
  402.   }
  403.   void insert(const_iterator __f, const_iterator __l) 
  404.     { _M_ht.insert_equal(__f, __l); }
  405. #endif /*__STL_MEMBER_TEMPLATES */
  406.   iterator insert_noresize(const value_type& __obj)
  407.     { return _M_ht.insert_equal_noresize(__obj); }    
  408.  
  409.   iterator find(const key_type& __key) { return _M_ht.find(__key); }
  410.   const_iterator find(const key_type& __key) const 
  411.     { return _M_ht.find(__key); }
  412.  
  413.   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
  414.   
  415.   pair<iterator, iterator> equal_range(const key_type& __key)
  416.     { return _M_ht.equal_range(__key); }
  417.   pair<const_iterator, const_iterator>
  418.   equal_range(const key_type& __key) const
  419.     { return _M_ht.equal_range(__key); }
  420.  
  421.   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
  422.   void erase(iterator __it) { _M_ht.erase(__it); }
  423.   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  424.   void clear() { _M_ht.clear(); }
  425.  
  426. public:
  427.   void resize(size_type __hint) { _M_ht.resize(__hint); }
  428.   size_type bucket_count() const { return _M_ht.bucket_count(); }
  429.   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  430.   size_type elems_in_bucket(size_type __n) const
  431.     { return _M_ht.elems_in_bucket(__n); }
  432. };
  433.  
  434. template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
  435. inline bool 
  436. operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
  437.            const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
  438. {
  439.   return __hm1._M_ht == __hm2._M_ht;
  440. }
  441.  
  442. #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
  443.  
  444. template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
  445. inline bool 
  446. operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
  447.            const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {
  448.   return !(__hm1 == __hm2);
  449. }
  450.  
  451. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  452. inline void 
  453. swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  454.      hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  455. {
  456.   __hm1.swap(__hm2);
  457. }
  458.  
  459. #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
  460.  
  461. // Specialization of insert_iterator so that it will work for hash_map
  462. // and hash_multimap.
  463.  
  464. #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
  465.  
  466. template <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
  467. class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  468. protected:
  469.   typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  470.   _Container* container;
  471. public:
  472.   typedef _Container          container_type;
  473.   typedef output_iterator_tag iterator_category;
  474.   typedef void                value_type;
  475.   typedef void                difference_type;
  476.   typedef void                pointer;
  477.   typedef void                reference;
  478.  
  479.   insert_iterator(_Container& __x) : container(&__x) {}
  480.   insert_iterator(_Container& __x, typename _Container::iterator)
  481.     : container(&__x) {}
  482.   insert_iterator<_Container>&
  483.   operator=(const typename _Container::value_type& __value) { 
  484.     container->insert(__value);
  485.     return *this;
  486.   }
  487.   insert_iterator<_Container>& operator*() { return *this; }
  488.   insert_iterator<_Container>& operator++() { return *this; }
  489.   insert_iterator<_Container>& operator++(int) { return *this; }
  490. };
  491.  
  492. template <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
  493. class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  494. protected:
  495.   typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  496.   _Container* container;
  497.   typename _Container::iterator iter;
  498. public:
  499.   typedef _Container          container_type;
  500.   typedef output_iterator_tag iterator_category;
  501.   typedef void                value_type;
  502.   typedef void                difference_type;
  503.   typedef void                pointer;
  504.   typedef void                reference;
  505.  
  506.   insert_iterator(_Container& __x) : container(&__x) {}
  507.   insert_iterator(_Container& __x, typename _Container::iterator)
  508.     : container(&__x) {}
  509.   insert_iterator<_Container>&
  510.   operator=(const typename _Container::value_type& __value) { 
  511.     container->insert(__value);
  512.     return *this;
  513.   }
  514.   insert_iterator<_Container>& operator*() { return *this; }
  515.   insert_iterator<_Container>& operator++() { return *this; }
  516.   insert_iterator<_Container>& operator++(int) { return *this; }
  517. };
  518.  
  519. #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
  520.  
  521. #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
  522. #pragma reset woff 1174
  523. #pragma reset woff 1375
  524. #endif
  525.  
  526. __STL_END_NAMESPACE
  527.  
  528. #endif /* __SGI_STL_INTERNAL_HASH_MAP_H */
  529.  
  530. // Local Variables:
  531. // mode:C++
  532. // End:
  533.